package com.net.xpay.common.domain.partner;

import com.net.common.domain.CommonDomain;
import com.net.xpay.core.enums.AccountBillType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author  on 17/03/2018.
 * 记录收支的明细
 */
@Getter
@Setter
@NoArgsConstructor
public class PartnerAccountLog extends CommonDomain {
    @ApiModelProperty(notes = "合伙人id")
    private Long partnerId;

    @ApiModelProperty(notes = "账单类别")
    private AccountBillType type;

    @ApiModelProperty(notes = "accountDetailId")
    private Long accountDetailId;

    @ApiModelProperty(notes = "关联id")
    private Long relatedId;

    @ApiModelProperty(notes = "相关的memo.")
    private String memo;

    @ApiModelProperty(notes = "变化的总数量 分")
    private Long change;

    @ApiModelProperty(notes = "变化前的金额 分")
    private Long beforeAmount;

    @ApiModelProperty(notes = "变化后的金额 分")
    private Long afterAmount;


    public static PartnerAccountLog getInstance(Partner partner, PartnerAccountDetail accountDetail) {
        PartnerAccountLog accountLog = new PartnerAccountLog();

        accountLog.setPartnerId(partner.getId());
        accountLog.setType(accountDetail.getType());
        accountLog.setAccountDetailId(accountDetail.getId());
        accountLog.setRelatedId(accountDetail.getRelatedId());
        accountLog.setChange(0L);
        return accountLog;
    }

}
